import qt_shiyong_rc
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
from mysql import mysql

class shuju_xianshi(object):
    def setupUi(self, shuju_xianshi):
        shuju_xianshi.setObjectName("shuju_xianshi")
        shuju_xianshi.resize(825, 590)
        shuju_xianshi.setMinimumSize(QtCore.QSize(825, 590))
        shuju_xianshi.setMaximumSize(QtCore.QSize(825, 590))
        shuju_xianshi.setStyleSheet("background-image: url(:/新前缀/好看的图片.jpg);")
        self.layoutWidget = QtWidgets.QWidget(shuju_xianshi)
        self.layoutWidget.setGeometry(QtCore.QRect(0, 120, 251, 111))
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_3 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout.addWidget(self.label_3)
        self.shuju_banji = QtWidgets.QSpinBox(self.layoutWidget)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.shuju_banji.setFont(font)
        self.shuju_banji.setObjectName("shuju_banji")
        self.horizontalLayout.addWidget(self.shuju_banji)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label_4 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_2.addWidget(self.label_4)
        self.shuju_didian = QtWidgets.QSpinBox(self.layoutWidget)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.shuju_didian.setFont(font)
        self.shuju_didian.setObjectName("shuju_didian")
        self.horizontalLayout_2.addWidget(self.shuju_didian)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.layoutWidget_4 = QtWidgets.QWidget(shuju_xianshi)
        self.layoutWidget_4.setGeometry(QtCore.QRect(300, 120, 501, 231))
        self.layoutWidget_4.setObjectName("layoutWidget_4")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.layoutWidget_4)
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.label_8 = QtWidgets.QLabel(self.layoutWidget_4)
        font = QtGui.QFont()
        font.setFamily("黑体")
        font.setPointSize(12)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.verticalLayout_3.addWidget(self.label_8)
        self.shuju_yiqian = QtWidgets.QTextBrowser(self.layoutWidget_4)
        self.shuju_yiqian.setStyleSheet("")
        self.shuju_yiqian.setObjectName("shuju_yiqian")
        self.verticalLayout_3.addWidget(self.shuju_yiqian)
        self.label_2 = QtWidgets.QLabel(shuju_xianshi)
        self.label_2.setGeometry(QtCore.QRect(20, 10, 491, 61))
        font = QtGui.QFont()
        font.setFamily("黑体")
        font.setPointSize(24)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.layoutWidget_2 = QtWidgets.QWidget(shuju_xianshi)
        self.layoutWidget_2.setGeometry(QtCore.QRect(0, 270, 251, 91))
        self.layoutWidget_2.setObjectName("layoutWidget_2")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.layoutWidget_2)
        self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_5 = QtWidgets.QLabel(self.layoutWidget_2)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout_3.addWidget(self.label_5)
        self.shuju_yingdao = QtWidgets.QLCDNumber(self.layoutWidget_2)
        self.shuju_yingdao.setObjectName("shuju_yingdao")
        self.horizontalLayout_3.addWidget(self.shuju_yingdao)
        self.verticalLayout_4.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.label_6 = QtWidgets.QLabel(self.layoutWidget_2)
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(16)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_4.addWidget(self.label_6)
        self.shuju_shidao = QtWidgets.QLCDNumber(self.layoutWidget_2)
        self.shuju_shidao.setObjectName("shuju_shidao")
        self.horizontalLayout_4.addWidget(self.shuju_shidao)
        self.verticalLayout_4.addLayout(self.horizontalLayout_4)
        self.shuju_shijian = QtWidgets.QLabel(shuju_xianshi)
        self.shuju_shijian.setGeometry(QtCore.QRect(480, 60, 351, 61))
        font = QtGui.QFont()
        font.setFamily("方正姚体")
        font.setPointSize(16)
        self.shuju_shijian.setFont(font)
        self.shuju_shijian.setObjectName("shuju_shijian")
        self.shuju_btn_cahxun = QtWidgets.QPushButton(shuju_xianshi)
        self.shuju_btn_cahxun.setGeometry(QtCore.QRect(30, 400, 171, 131))
        font = QtGui.QFont()
        font.setFamily("Agency FB")
        font.setPointSize(24)
        self.shuju_btn_cahxun.setFont(font)
        self.shuju_btn_cahxun.setStyleSheet("image: url(:/新前缀/查询.png);")
        self.shuju_btn_cahxun.setText("")
        self.shuju_btn_cahxun.setObjectName("shuju_btn_cahxun")
        self.layoutWidget_3 = QtWidgets.QWidget(shuju_xianshi)
        self.layoutWidget_3.setGeometry(QtCore.QRect(300, 370, 501, 191))
        self.layoutWidget_3.setObjectName("layoutWidget_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget_3)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.label_7 = QtWidgets.QLabel(self.layoutWidget_3)
        font = QtGui.QFont()
        font.setFamily("黑体")
        font.setPointSize(12)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.verticalLayout_2.addWidget(self.label_7)
        self.shuju_weiqian = QtWidgets.QTextBrowser(self.layoutWidget_3)
        self.shuju_weiqian.setStyleSheet("")
        self.shuju_weiqian.setObjectName("shuju_weiqian")
        self.verticalLayout_2.addWidget(self.shuju_weiqian)
        self.shuju_zhuangtailan = QtWidgets.QTextBrowser(shuju_xianshi)
        self.shuju_zhuangtailan.setGeometry(QtCore.QRect(0, 560, 831, 31))
        self.shuju_zhuangtailan.setObjectName("shuju_zhuangtailan")

        self.retranslateUi(shuju_xianshi)
        QtCore.QMetaObject.connectSlotsByName(shuju_xianshi)

    def retranslateUi(self, shuju_xianshi):
        _translate = QtCore.QCoreApplication.translate
        shuju_xianshi.setWindowTitle(_translate("shuju_xianshi", "学生打卡数据显示"))
        self.label_3.setText(_translate("shuju_xianshi", "考勤班级："))
        self.label_4.setText(_translate("shuju_xianshi", "考勤地点："))
        self.label_8.setText(_translate("shuju_xianshi", "已签："))
        self.label_2.setText(_translate("shuju_xianshi", "人脸识别学生打卡信息数据"))
        self.label_5.setText(_translate("shuju_xianshi", "应到："))
        self.label_6.setText(_translate("shuju_xianshi", "实到："))
        self.shuju_shijian.setText(_translate("shuju_xianshi", "周二 4月18日 20:17:35 2021"))
        self.label_7.setText(_translate("shuju_xianshi", "未签："))
        self.shuju_zhuangtailan.setHtml("信息提示")
        
        # 设置槽函数
        self.shuju_btn_cahxun.clicked.connect(self.chaxun)
         # 给按键设置提示
        self.shuju_btn_cahxun.setToolTip("考勤信息查询")
        

    def chaxun(self):
        self.shuju_zhuangtailan.setHtml("信息正在查询，请稍等")
        banji = str(self.shuju_banji.value())
        didian = str(self.shuju_didian.value())
        if banji !='0' and didian != '0':
            select_kaoqin = mysql(banji= banji)
            state = select_kaoqin.select_kaoqin(didian = didian)
            if state == 1:
                self.shuju_yiqian.setText(select_kaoqin.banji_daka)
                self.shuju_weiqian.setText(select_kaoqin.banji_weidaka)
                self.shuju_yingdao.display(select_kaoqin.yingdao)
                self.shuju_shidao.display(select_kaoqin.shidao)
                self.shuju_zhuangtailan.setHtml("学生查询成功")
            else:
                self.shuju_zhuangtailan.setHtml("信息查询失败，错误代码：" + str(state) )
        else:
            self.shuju_zhuangtailan.setHtml("请输入要查询的班级和地点")


        
